package com.gis.postgis.geojson.collection;

import java.util.Arrays;
import java.util.List;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.gis.postgis.geojson.annotation.GeoJsonBbox;
import com.gis.postgis.geojson.annotation.GeoJsonFeatures;
import com.gis.postgis.geojson.annotation.GeoJsonType;
import com.gis.postgis.geojson.deserializer.GeoJsonDeserializer;
import com.gis.postgis.geojson.serializer.FeatureType;
import com.gis.postgis.geojson.serializer.GeoJsonSerializer;
/**
 * 〈功能简述〉<br>
 * 〈封装Feature集合〉
 *
 * @author Mr.QL
 * @ClassName FeatureCollection
 * @Date 2022-03-13 0:12
 * @Version 1.0
 */
@GeoJsonType(type = FeatureType.FEATURE_COLLECTION)
@JsonSerialize(using = GeoJsonSerializer.class)
@JsonDeserialize(using = GeoJsonDeserializer.class)
public class FeatureCollection<T> {

    public FeatureCollection() {
    }

    private List<T> list;

    private double[] bbox;

    @GeoJsonFeatures
    public List<T> getList() {
        return list;
    }

    public void setList(List<T> list) {
        this.list = list;
    }

    @GeoJsonBbox
    public double[] getBbox() {
        return bbox;
    }

    public void setBbox(double[] bbox) {
        this.bbox = bbox;
    }

    public FeatureCollection build(List<T> list){
        this.list = list;
        return this;
    }
    public FeatureCollection build(List<T> list,double[] bbox){
        this.list = list;
        this.bbox = bbox;
        return this;
    }

    @Override
    public String toString() {
        return "FeatureCollection{" +
                "list=" + list +
                ", bbox=" + Arrays.toString(bbox) +
                '}';
    }
}
